package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface DishMapper {


    @Select("select count(*) from dish where category_id=#{id}")
    Long deleteByCategoryId(Long id);


    /**
     * 新增菜品
     * @param dish
     */
    void insert(Dish dish);


    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);



    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);


    /**
     * 修改
     * @param dish
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 根据查询对应的状态
     * @param ids
     * @return
     */
    List<Integer> getStatusByDishId(List<Long> ids);


    /**
     * 批量删除
     * @param ids
     */
    void deleteBatch(List<Long> ids);


    @Update("update dish set status=#{status} where id = #{id}")
    void startAndStop(Integer status,Long id);



    @Select("select * from dish where category_id=#{categoryId}")
    ArrayList<Dish> findByCategoryId(Long categoryId);
}
